<?php
// php.exe E:\qh\speed\cli.php /app/home/worker/msgIm
error_reporting(0);
define('APP_DIR', realpath('./'));
define('APP_EVN', 'nginx');
define('APP_SYS', 'windows');
$GLOBALS += require(APP_DIR . '/config.php');
require(APP_DIR . '/lib/core.php');
$app = new Core();
$app->server = $_SERVER;
$app->header = apache_request_headers();
header("Server: FoxBoot/v1.0");
$controller_name = str_replace('/', '\\', $GLOBALS['argv'][1]);
$arr = explode('\\', $controller_name);
$app->app_module = !empty($arr[1]) ? strtolower($arr[1]) : 'home';
$app->app_controller = !empty($arr[2]) ? strtolower($arr[2]) : 'main';
$app->app_action = !empty($arr[3]) ? strtolower($arr[3]) : 'index';
$app->request = array_merge($_GET, $_POST);
if (!empty($app->app_module)) if (!is_available_className($app->app_module)) return err("Err: Module '$app->app_module' is not correct!");
if (!is_available_className($app->app_controller)) return err("Err: Controller '$controller_name' is not correct!");
if (!class_exists($controller_name, true)) return err("Err: Controller '$controller_name' is not exists!");
if (!method_exists($controller_name, $app->app_action)) return err("Err: Method '$app->app_action' of '$controller_name' is not exists!");
$controller_obj = new $controller_name($app);
call_user_func_array(array($controller_obj, $app->app_action), count($arr) > 4 ? array_slice($arr, 4) : array());